package com.ruoyi.web.controller.yf;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yf.domain.YfOutstoreRecord;
import com.ruoyi.yf.service.IYfOutstoreRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医废出库记录Controller
 * 
 * @author XiaoYi...
 * @date 2020-07-21
 * 34d4d583-451d-437c-858f-3ac7e9c24786
 */
@Controller
@RequestMapping("/yf/outstorerecord")
public class YfOutstoreRecordController extends BaseController
{
    private String prefix = "yf/outstorerecord";

    @Autowired
    private IYfOutstoreRecordService yfOutstoreRecordService;

    @RequiresPermissions("yf:outstorerecord:view")
    @GetMapping()
    public String outstorerecord()
    {
        return prefix + "/outstorerecord";
    }

    /**
     * 查询医废出库记录列表
     * bd500953-5c41-449c-b35c-722333c0c10e
     */
    @RequiresPermissions("yf:outstorerecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YfOutstoreRecord yfOutstoreRecord)
    {
        startPage();
        List<YfOutstoreRecord> list = yfOutstoreRecordService.selectYfOutstoreRecordList(yfOutstoreRecord);
        return getDataTable(list);
    }

    /**
     * 导出医废出库记录列表
     * 7ba69605-a18f-4505-badf-1d32f7442e04
     */
    @RequiresPermissions("yf:outstorerecord:export")
    @Log(title = "医废出库记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YfOutstoreRecord yfOutstoreRecord)
    {
        List<YfOutstoreRecord> list = yfOutstoreRecordService.selectYfOutstoreRecordList(yfOutstoreRecord);
        ExcelUtil<YfOutstoreRecord> util = new ExcelUtil<YfOutstoreRecord>(YfOutstoreRecord.class);
        return util.exportExcel(list, "outstorerecord");
    }

    /**
     * 新增医废出库记录
     * 0aa1e3a8-94cd-44c9-85a7-8289acdfe9d1
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存医废出库记录
     * 6dd1e94c-fec4-4714-bda5-e6926df71c96
     */
    @RequiresPermissions("yf:outstorerecord:add")
    @Log(title = "医废出库记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YfOutstoreRecord yfOutstoreRecord)
    {
        return toAjax(yfOutstoreRecordService.insertYfOutstoreRecord(yfOutstoreRecord));
    }

    /**
     * 修改医废出库记录
     * b90646ab-acf6-46a3-9335-723149e29d24
     */
    @GetMapping("/edit/{codeid}")
    public String edit(@PathVariable("codeid") String codeid, ModelMap mmap)
    {
        YfOutstoreRecord yfOutstoreRecord = yfOutstoreRecordService.selectYfOutstoreRecordById(codeid);
        mmap.put("yfOutstoreRecord", yfOutstoreRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存医废出库记录
     * 7632b569-ce55-4e3d-b745-4bde00d2a2c2
     */
    @RequiresPermissions("yf:outstorerecord:edit")
    @Log(title = "医废出库记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YfOutstoreRecord yfOutstoreRecord)
    {
        return toAjax(yfOutstoreRecordService.updateYfOutstoreRecord(yfOutstoreRecord));
    }

    /**
     * 删除医废出库记录
     * d2e28285-b31d-4d13-a390-99cf375ab47e
     */
    @RequiresPermissions("yf:outstorerecord:remove")
    @Log(title = "医废出库记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yfOutstoreRecordService.deleteYfOutstoreRecordByIds(ids));
    }
}
